package nodo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Pila {
	
	static BufferedReader leer = new BufferedReader(new InputStreamReader(System.in));
	private static Object dato;
	static Nodo tope;
	
	static class Nodo{
		Object info;
		Nodo sig;
	}
	
	

	public Pila() {
		tope=null;
	}

	public static void main(String[] args) {
		
			
			System.out.print("\n num datos");
			int n=0;
			try {
				n = Integer.parseInt(leer.readLine());
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			insertar(n);
		
		
		
		
	}
	
	public static void insertar(int n){
		for(int i=0;i<n;i++){
			Nodo nuevo = new Nodo();
			System.out.print("\n inserte dato "+i+": ");
			try {
				dato=leer.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			nuevo.info=dato;
			
			if(tope==null){
				nuevo.sig=null;
				tope=nuevo;			
			}
			else
			{
				nuevo.sig=tope;
				tope=nuevo;
			}	
			System.out.print("\n nodo Nº :"+nuevo);
			System.out.print("\n dato :"+nuevo.info);
			System.out.print("\n siguiente :"+nuevo.sig);
		}
		
			
		}		
		
	}


